/**
 * Date Modified: $Date: 2009-08-28 10:39:55 +1000 (Fri, 28 Aug 2009) $
 * Version: $Revision: 129 $
 * 
 * Copyright 2008 The Australian National University (ANU)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//package org.ands.rifcs.example;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.*;

import javax.xml.parsers.ParserConfigurationException;


import org.ands.rifcs.base.*;

import org.xml.sax.SAXException;

public class BioGrid
{
	private static RIFCS rifcs = null;

    public static void main(String[] args) throws RIFCSException, FileNotFoundException, SAXException, ParserConfigurationException, IOException
    {
        RIFCSWrapper mw = new RIFCSWrapper();
        rifcs = mw.getRIFCSObject();

        RegistryObject r = rifcs.newRegistryObject();
    
        r.setKey("www.biogrid.gov.au");
        r.setGroup("BioGrid");
        r.setOriginatingSource("https://services.ands.org.au/sandbox/orca");
        
        Service ser = r.newService();
        ser.setType("search-http");
        ser.setDateModified("2011-03-16T04:49:00Z");
        
        Name n1 = ser.newName();
        n1.setType("primary");
        NamePart np = n1.newNamePart();
        np.setType("title");
        np.setValue("BioGrid Australia");
        n1.addNamePart(np);
        ser.addName(n1);
        
        Location loc = ser.newLocation();
        Address add = loc.newAddress();
        Electronic elec = add.newElectronic();
        elec.setType("url");
        elec.setValue("www.biogrid.gov.au");
        add.addElectronic(elec);
        loc.addAddress(add);
        ser.addLocation(loc);
        
        Description des = ser.newDescription();
        des.setType("brief");
        des.setValue("BioGrid Australia provides researchers access to data in many disease types and data from disparate existing databases at many institutions.");
        ser.addDescription(des);
        
        AccessPolicy ap = ser.newAccessPolicy();
        ap.setValue("http://www.biogrid.org.au/wps/portal/biogridwcm/?WCM_GLOBAL_CONTEXT=/wps/wcm/connect/biogrid+australia/biogrid+australia/Data/How+to+access+Data/");
        ser.addAccessPolicy(ap);
        r.addService(ser);
        rifcs.addRegistryObject(r);
        
       
        
	    mw.validate();

	    FileOutputStream outputFile=null;
	    try{
	    	outputFile = new FileOutputStream("biogrid.xml");
	    	
	    }
	    catch(IOException e1){
	    	System.out.println("Error writing to biogrid.xml");
	    }
	    
		//mw.write(System.out);
		mw.write(outputFile);
		System.out.println("Successfully written to XML file.");
    }
}